<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>戴努努高考必中查询系统</title>
    <style>
        :root {
            --primary-color: #8e44ad;
            --secondary-color: #af8dc3;
            --accent-color: #f3e5f5;
            --text-color: #333;
            --light-text: #666;
            --border-color: #ddd;
            --hover-color: #9970a5;
        }

        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f5f5f5;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            overflow: hidden;
        }

        .header {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            padding: 25px;
            color: white;
        }

        .header h1 {
            margin: 0;
            font-size: 24px;
            font-weight: bold;
            text-align: center;
            margin-bottom: 25px;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
        }

        .prediction-inputs {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 15px;
            margin-bottom: 20px;
        }

        .input-group {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .score-input, .rank-input {
            width: 180px;
            padding: 12px 20px;
            border: 2px solid rgba(255,255,255,0.3);
            border-radius: 25px;
            font-size: 16px;
            text-align: center;
            transition: all 0.3s;
            background: rgba(255,255,255,0.9);
        }

        .score-input:focus, .rank-input:focus {
            outline: none;
            border-color: white;
            box-shadow: 0 0 0 3px rgba(255,255,255,0.2);
        }

        .predict-button {
            background: var(--accent-color);
            color: var(--primary-color);
            padding: 12px 30px;
            border: none;
            border-radius: 25px;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s;
            font-weight: bold;
        }

        .predict-button:hover {
            background: white;
            transform: translateY(-2px);
        }

        .or-text {
            color: white;
            font-size: 16px;
            margin: 0 10px;
        }

        .search-section {
            margin-top: 20px;
            display: flex;
            gap: 15px;
            background: rgba(255,255,255,0.1);
            padding: 15px;
            border-radius: 8px;
        }

        .search-section input {
            flex: 1;
            padding: 12px;
            padding-left: 35px;
            border: 2px solid rgba(255,255,255,0.2);
            border-radius: 6px;
            font-size: 16px;
            background: rgba(255,255,255,0.9);
            transition: all 0.3s ease;
        }

        .search-section input:focus {
            outline: none;
            border-color: white;
            box-shadow: 0 0 8px rgba(255,255,255,0.3);
        }

        .filter-section {
            background: rgba(255,255,255,0.1);
            padding: 15px;
            border-radius: 8px;
            margin-top: 15px;
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            align-items: center;
        }

        .filter-group {
            flex: 1;
            min-width: 180px;
            margin: 0;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .filter-group h3 {
            color: white;
            margin: 0;
            font-size: 14px;
            font-weight: bold;
            white-space: nowrap;
        }

        .filter-group select {
            flex: 1;
            padding: 8px;
            border: 2px solid rgba(255,255,255,0.2);
            border-radius: 6px;
            font-size: 14px;
            background: rgba(255,255,255,0.9);
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .filter-group select:hover {
            border-color: white;
        }

        .filter-group select:focus {
            outline: none;
            border-color: white;
            box-shadow: 0 0 5px rgba(255,255,255,0.3);
        }

        .major-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 15px;
            padding: 20px;
            background: white;
        }

        .major-card {
            background: white;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            cursor: pointer;
            transition: all 0.3s ease;
            border: 1px solid var(--border-color);
            display: flex;
            flex-direction: column;
            gap: 12px;
            position: relative;
        }

        .major-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
            border-color: var(--primary-color);
        }

        .major-card h3 {
            margin: 0;
            color: var(--primary-color);
            font-size: 18px;
            font-weight: bold;
            border-bottom: 2px solid var(--accent-color);
            padding-bottom: 8px;
        }

        .major-card .rating {
            display: inline-block;
            padding: 4px 12px;
            background-color: var(--accent-color);
            color: var(--primary-color);
            border-radius: 20px;
            font-size: 14px;
            font-weight: bold;
        }

        .major-card .stats {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }

        .major-card .stat-item {
            font-size: 13px;
            padding: 4px 12px;
            background-color: #f5f5f5;
            border-radius: 15px;
            color: var(--light-text);
            border: 1px solid var(--border-color);
        }

        .major-card .description {
            font-size: 14px;
            color: var(--light-text);
            margin: 0;
            line-height: 1.5;
        }

        .admission-prediction {
            margin-top: 8px;
            padding: 8px 12px;
            border-radius: 6px;
            font-weight: bold;
            text-align: center;
        }

        .high-chance {
            background-color: #e8f5e9;
            color: #2e7d32;
            border: 1px solid #a5d6a7;
        }

        .medium-chance {
            background-color: #fff3e0;
            color: #f57c00;
            border: 1px solid #ffcc80;
        }

        .low-chance {
            background-color: #ffebee;
            color: #c62828;
            border: 1px solid #ef9a9a;
        }

        .major-details {
            display: none;
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: white;
            padding: 30px;
            border-radius: 12px;
            box-shadow: 0 5px 25px rgba(0,0,0,0.15);
            max-width: 800px;
            width: 90%;
            max-height: 85vh;
            overflow-y: auto;
            z-index: 1000;
        }

        .overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0,0,0,0.6);
            z-index: 999;
            backdrop-filter: blur(3px);
        }

        .close-button {
            position: absolute;
            top: 15px;
            right: 15px;
            background: none;
            border: none;
            font-size: 28px;
            cursor: pointer;
            color: var(--primary-color);
            transition: all 0.3s ease;
        }

        .close-button:hover {
            color: var(--hover-color);
            transform: rotate(90deg);
        }

        .detail-content {
            line-height: 1.8;
            color: var(--text-color);
        }

        .detail-content h1, 
        .detail-content h2, 
        .detail-content h3 {
            color: var(--primary-color);
            border-bottom: 2px solid var(--accent-color);
            padding-bottom: 8px;
            margin: 25px 0 15px 0;
        }

        .detail-content p {
            margin: 15px 0;
            color: var(--light-text);
        }

        .detail-content ul {
            margin: 15px 0;
            padding-left: 20px;
        }

        .detail-content li {
            margin: 8px 0;
            color: var(--light-text);
        }

        .recommendation-section {
            padding: 20px;
            background: white;
            border-radius: 0 0 10px 10px;
            display: none;
        }

        .recommendation-section h3 {
            color: var(--primary-color);
            margin: 0 0 20px 0;
            font-size: 20px;
            text-align: center;
        }

        .school-item {
            background: white;
            padding: 16px 15px;
            margin: 10px 0;
            border-radius: 8px;
            box-shadow: 0 3px 6px rgba(0,0,0,0.08);
            transition: all 0.3s ease;
            cursor: pointer;
            border: 1px solid var(--border-color);
        }

        .school-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
            border-color: var(--primary-color);
            background: var(--accent-color);
        }

        .school-name {
            font-weight: bold;
            color: var(--primary-color);
            margin-bottom: 12px;
            font-size: 16px;
            padding-bottom: 8px;
            border-bottom: 1px solid #f0e6f5;
        }

        .school-stats {
            display: flex;
            gap: 10px;
            font-size: 13px;
            color: var(--light-text);
        }

        .school-stats-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
            margin-top: 10px;
        }

        .school-stat {
            background: #f5f5f5;
            padding: 8px 10px;
            border-radius: 8px;
            font-size: 14px;
            color: var(--light-text);
            text-align: center;
            border: 1px solid #e8e8e8;
            min-height: 50px;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }

        .school-stat strong {
            color: var(--primary-color);
            font-weight: bold;
            display: block;
            margin-top: 2px;
        }

        .school-stats span {
            background: #f5f5f5;
            padding: 2px 8px;
            border-radius: 10px;
            white-space: nowrap;
        }

        .recommendation-group {
            background: var(--accent-color);
            padding: 15px;
            border-radius: 8px;
        }

        .recommendation-group h4 {
            color: var(--primary-color);
            margin: 0 0 15px 0;
            padding-bottom: 10px;
            border-bottom: 2px solid var(--primary-color);
            font-size: 16px;
            text-align: center;
        }

        .recommendation-content {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 20px;
            margin-top: 15px;
        }

        .parallel-info {
            grid-column: 1 / -1;
            background: var(--accent-color);
            padding: 15px;
            border-radius: 8px;
            margin-top: 15px;
        }

        .parallel-info p {
            color: var(--primary-color);
            font-weight: bold;
            margin: 0 0 10px 0;
        }

        .parallel-info ul {
            margin: 0;
            padding-left: 20px;
            color: var(--text-color);
        }

        .parallel-info li {
            margin: 5px 0;
        }

        .school-tag {
            display: inline-block;
            padding: 5px 10px;
            margin: 5px;
            background-color: white;
            border-radius: 4px;
            text-decoration: none;
            color: var(--text-color);
            transition: all 0.2s;
            border: 1px solid #ddd;
        }

        .school-tag:hover {
            background-color: var(--primary-color);
            color: white;
            transform: translateY(-2px);
        }

        .school-tag.not-found {
            opacity: 0.7;
            cursor: not-allowed;
        }

        .parallel-tag {
            display: inline-block;
            padding: 2px 6px;
            margin: 0 2px;
            border-radius: 3px;
            font-size: 12px;
            background: var(--accent-color);
        }

        /* 小猪对话框样式 */
        .pig-dialog {
            display: none;
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: #ffebee;
            border: 3px solid #ff8a80;
            border-radius: 20px;
            padding: 20px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
            z-index: 1100;
            text-align: center;
            max-width: 300px;
            animation: bounce 0.5s;
        }

        .pig-dialog::before {
            content: '🐷';
            display: block;
            font-size: 50px;
            margin-bottom: 10px;
        }

        .pig-dialog-message {
            font-size: 18px;
            color: #d32f2f;
            font-weight: bold;
            margin: 10px 0;
        }

        .pig-dialog-close {
            background: #ff8a80;
            color: white;
            border: none;
            border-radius: 15px;
            padding: 5px 15px;
            margin-top: 10px;
            cursor: pointer;
            font-weight: bold;
            transition: all 0.2s;
        }

        .pig-dialog-close:hover {
            background: #ff5252;
            transform: scale(1.05);
        }

        @keyframes bounce {
            0% { transform: translate(-50%, -50%) scale(0.5); }
            70% { transform: translate(-50%, -50%) scale(1.1); }
            100% { transform: translate(-50%, -50%) scale(1); }
        }

        .major-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
            border-bottom: 2px solid var(--accent-color);
            padding-bottom: 8px;
        }

        .major-header h3 {
            margin: 0;
            padding-bottom: 0;
            border-bottom: none;
            font-size: 18px;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 10px;
            margin: 15px 0;
        }

        .stat-box {
            background-color: #f9f6fb;
            border-radius: 8px;
            padding: 8px;
            text-align: center;
            border: 1px solid #f0e6f5;
        }

        .stat-label {
            color: var(--light-text);
            font-size: 12px;
            margin-bottom: 4px;
        }

        .stat-value {
            color: var(--primary-color);
            font-weight: bold;
            font-size: 16px;
        }

        .major-name {
            font-size: 18px;
            color: var(--primary-color);
            margin-bottom: 15px;
        }

        .admission-row {
            display: flex;
            gap: 10px;
            margin: 5px 0;
        }

        .admission-label {
            color: var(--light-text);
            font-size: 14px;
        }

        .admission-value {
            color: var(--primary-color);
            font-weight: bold;
            font-size: 14px;
        }

        .priority-info {
            display: flex;
            gap: 10px;
            margin-top: 10px;
        }

        .priority-tag, .adjustment-tag {
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
            background: var(--accent-color);
            color: var(--primary-color);
        }

        .admission-info {
            display: flex;
            gap: 10px;
            margin: 8px 0;
        }

        .admission-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 8px;
            margin: 12px 0;
        }

        .admission-info .stat-item,
        .admission-grid .stat-item {
            background-color: #f2f2fa;
            border: 1px solid #e0e0f0;
            text-align: center;
            padding: 12px 8px;
            border-radius: 8px;
            min-height: 60px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            white-space: normal;
            overflow: visible;
        }
        
        .admission-grid .stat-item .stat-label {
            color: var(--light-text);
            font-size: 13px;
            margin-bottom: 4px;
        }
        
        .admission-grid .stat-item .stat-value {
            color: var(--primary-color);
            font-weight: bold;
            font-size: 16px;
        }

        .major-card .stats {
            flex-wrap: wrap;
            gap: 8px;
        }

        .major-card .stat-item {
            font-size: 13px;
            padding: 4px 12px;
            background-color: #f5f5f5;
            border-radius: 15px;
            color: var(--light-text);
            border: 1px solid var(--border-color);
            white-space: nowrap;
        }

        @media (max-width: 768px) {
            .container {
                padding: 10px;
            }

            .header {
                padding: 10px;
            }

            .filter-section {
                padding: 10px;
                flex-direction: column;
            }

            .filter-group {
                width: 100%;
            }

            .major-grid {
                grid-template-columns: 1fr;
            }

            .major-card {
                padding: 15px;
            }

            .recommendation-content {
                grid-template-columns: 1fr;
            }

            .school-stats {
                flex-wrap: wrap;
            }

            .recommendation-group {
                min-height: auto;
            }

            .parallel-info {
                margin-top: 15px;
            }

            .stats-grid {
                grid-template-columns: repeat(2, 1fr);
            }

            .admission-grid {
                grid-template-columns: repeat(2, 1fr);
            }

            .school-stats-grid {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        /* 录取率悬停提示样式 */
        .tooltip {
            position: relative;
            display: inline-block;
            cursor: help;
        }

        .tooltip .tooltip-text {
            visibility: hidden;
            width: 320px;
            background-color: rgba(0,0,0,0.8);
            color: #fff;
            text-align: center;
            border-radius: 6px;
            padding: 10px;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            transform: translateX(-50%);
            opacity: 0;
            transition: opacity 0.3s;
            font-size: 12px;
            line-height: 1.5;
        }

        .tooltip .tooltip-text::after {
            content: "";
            position: absolute;
            top: 100%;
            left: 50%;
            margin-left: -5px;
            border-width: 5px;
            border-style: solid;
            border-color: rgba(0,0,0,0.8) transparent transparent transparent;
        }

        .tooltip:hover .tooltip-text {
            visibility: visible;
            opacity: 1;
        }

        /* 录取率样式 */
        .high-admission-rate {
            color: #2e7d32 !important;
            font-weight: bold;
        }
        
        .medium-admission-rate {
            color: #f57c00 !important;
            font-weight: bold;
        }
        
        .low-admission-rate {
            color: #c62828 !important;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>努努志愿必中预测系统</h1>
            <div class="prediction-inputs">
                <div class="input-group">
                    <input type="number" id="scoreInput" class="score-input" placeholder="输入高考分数">
                </div>
                <span class="or-text">或</span>
                <div class="input-group">
                    <input type="number" id="rankInput" class="rank-input" placeholder="输入位次">
                </div>
                <button class="predict-button" onclick="predictAdmission()">预测录取概率</button>
            </div>
            <div class="search-section">
                <input type="text" id="searchInput" placeholder="搜索学校或专业名称">
            </div>
            <div class="filter-section">
                <div class="filter-group">
                    <h3>学校</h3>
                    <select id="schoolFilter">
                        <option value="">全部</option>
                    </select>
                </div>
                <div class="filter-group">
                    <h3>评级</h3>
                    <select id="ratingFilter">
                        <option value="">全部</option>
                        <option value="A+">A+</option>
                        <option value="A">A</option>
                        <option value="B+">B+</option>
                        <option value="B">B</option>
                    </select>
                </div>
                <div class="filter-group">
                    <h3>就业率</h3>
                    <select id="employmentFilter">
                        <option value="">全部</option>
                        <option value="95">95%以上</option>
                        <option value="90">90%以上</option>
                        <option value="85">85%以上</option>
                        <option value="80">80%以上</option>
                    </select>
                </div>
                <div class="filter-group">
                    <h3>保研率</h3>
                    <select id="postgraduateFilter">
                        <option value="">全部</option>
                        <option value="50">50%以上</option>
                        <option value="40">40%以上</option>
                        <option value="30">30%以上</option>
                        <option value="20">20%以上</option>
                    </select>
                </div>
                <div class="filter-group">
                    <h3>薪资</h3>
                    <select id="salaryFilter">
                        <option value="">全部</option>
                        <option value="15000">15000以上</option>
                        <option value="12000">12000以上</option>
                        <option value="10000">10000以上</option>
                        <option value="8000">8000以上</option>
                    </select>
                </div>
                <div class="filter-group">
                    <h3>排序</h3>
                    <select id="sortFilter">
                        <option value="">默认</option>
                        <option value="admission-desc">录取率从高到低</option>
                        <option value="admission-asc">录取率从低到高</option>
                        <option value="salary-desc">薪资从高到低</option>
                        <option value="salary-asc">薪资从低到高</option>
                        <option value="employment-desc">就业率从高到低</option>
                        <option value="employment-asc">就业率从低到高</option>
                        <option value="postgraduate-desc">保研率从高到低</option>
                        <option value="postgraduate-asc">保研率从低到高</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="recommendation-section" id="recommendationSection">
            <h3>志愿填报建议</h3>
            <div class="recommendation-content">
                <div class="recommendation-group">
                    <h4>冲刺院校 (30%)</h4>
                    <div id="highRiskSchools"></div>
                </div>
                <div class="recommendation-group">
                    <h4>稳妥院校 (40%)</h4>
                    <div id="mediumRiskSchools"></div>
                </div>
                <div class="recommendation-group">
                    <h4>保底院校 (30%)</h4>
                    <div id="lowRiskSchools"></div>
                </div>
                <div class="parallel-info">
                    <p>平行志愿填报建议：</p>
                    <ul>
                        <li>按照"冲稳保"比例为3:4:3的原则填报</li>
                        <li>同一批次内按照分数优先原则投档</li>
                        <li>建议服从专业调剂以增加录取机会</li>
                        <li>可以参考往年各专业的投档线和计划人数</li>
                    </ul>
                </div>
            </div>
        </div>
        <div id="majorGrid" class="major-grid"></div>
    </div>

    <!-- 小猪对话框 -->
    <div id="pigDialog" class="pig-dialog">
        <div class="pig-dialog-message">祝你成功！</div>
        <button class="pig-dialog-close" onclick="closePigDialog()">好的</button>
    </div>

    <script>
        // 专业数据
        const majorsData = [
            {
                school: "中国石油大学",
                major: "油气储运",
                rating: "A+",
                file: "中国石油大学_油气储运.md",
                employmentRate: 98.2,
                postgraduateRate: 45.0,
                averageSalary: 9000,
                description: "培养油气管道、储运、设计、燃气公司等领域的专业人才",
                minScore: 601,
                minRank: 7200,
                planCount: 2,
                guidePageNum: 362,
                planPageNum: 366,
                planCount2025: 2,
                notes: ""
            },
            {
                school: "北京中医药大学",
                major: "中医学",
                rating: "A+",
                file: "北京中医药大学_中医学.md",
                employmentRate: 97.0,
                postgraduateRate: 45.8,
                averageSalary: 18750,
                description: "培养中医医院、研究机构、健康产业等领域的专业人才",
                minScore: 605,
                minRank: 10000,
                planCount: null,
                guidePageNum: 99,
                planPageNum: 104,
                planCount2025: null,
                notes: ""
            },
            {
                school: "华东理工大学",
                major: "化学工程与工艺",
                rating: "A+",
                file: "华东理工大学_化学工程与工艺.md",
                employmentRate: 97.0,
                postgraduateRate: 55.0,
                averageSalary: 8000,
                description: "培养化工研发、生产、设计、技术服务等领域的专业人才",
                minScore: 610,
                minRank: 5200,
                planCount: 2,
                guidePageNum: 161,
                planPageNum: 162,
                planCount2025: 2,
                notes: ""
            },
            {
                school: "北京化工大学",
                major: "化学工程与工艺",
                rating: "A+",
                file: "北京化工大学_化学工程与工艺.md",
                employmentRate: 94.5,
                postgraduateRate: 55.5,
                averageSalary: 11500,
                description: "培养化工、石油化工、医药、新材料等领域的专业人才",
                minScore: null,
                minRank: 7400,
                planCount: null,
                guidePageNum: 94,
                planPageNum: 99,
                planCount2025: 12,
                notes: ""
            },
            {
                school: "北京化工大学",
                major: "能源化学工程",
                rating: "A+",
                file: "北京化工大学_能源化学工程.md",
                employmentRate: 93.8,
                postgraduateRate: 52.5,
                averageSalary: 10750,
                description: "培养能源化工、石油化工、新能源、环境工程等领域的专业人才",
                minScore: null,
                minRank: 7400,
                planCount: 12,
                guidePageNum: 94,
                planPageNum: 99,
                planCount2025: 12,
                notes: ""
            },
            {
                school: "北京化工大学",
                major: "氢能科学与工程",
                rating: "A+",
                file: "北京化工大学_氢能科学与工程.md",
                employmentRate: 93.5,
                postgraduateRate: 52.8,
                averageSalary: 13000,
                description: "培养氢能技术、新能源汽车、能源装备制造等领域的专业人才",
                minScore: null,
                minRank: 7400,
                planCount: null,
                guidePageNum: 94,
                planPageNum: 99,
                planCount2025: 12,
                notes: ""
            },
            {
                school: "对外经济贸易大学",
                major: "金融学",
                rating: "A+",
                file: "对外经济贸易大学_金融学.md",
                employmentRate: 95.8,
                postgraduateRate: 48.5,
                averageSalary: 18500,
                description: "培养银行、证券、保险、金融科技等领域的专业人才",
                minScore: 605,
                minRank: 6200,
                planCount: 8,
                guidePageNum: 103,
                planPageNum: 108,
                planCount2025: 8,
                notes: ""
            },
            {
                school: "华北电力大学",
                major: "机器人工程",
                rating: "A",
                file: "华北电力大学_机器人工程.md",
                employmentRate: 92.5,
                postgraduateRate: 45.6,
                averageSalary: 12500,
                description: "培养智能制造、机器人研发、自动化企业等领域的专业人才",
                minScore: 605,
                minRank: 6200,
                planCount: 1,
                guidePageNum: 362,
                planPageNum: 366,
                planCount2025: 1,
                notes: ""
            },
            {
                school: "江南大学",
                major: "自动化",
                rating: "A",
                file: "江南大学_自动化.md",
                employmentRate: 95.8,
                postgraduateRate: 42.0,
                averageSalary: 7500,
                description: "培养工业自动化、智能制造、机器人等领域的专业人才",
                minScore: 604,
                minRank: 6400,
                planCount: 3,
                guidePageNum: 175,
                planPageNum: 182,
                planCount2025: 3,
                notes: ""
            },
            {
                school: "江南大学",
                major: "食品科学与工程",
                rating: "A+",
                file: "江南大学_食品科学与工程.md",
                employmentRate: 94.2,
                postgraduateRate: 48.5,
                averageSalary: 9250,
                description: "培养食品研发、生产、质量控制、监管等领域的专业人才",
                minScore: 605,
                minRank: 6200,
                planCount: 3,
                guidePageNum: 175,
                planPageNum: 182,
                planCount2025: 3,
                notes: ""
            },
            {
                school: "北京中医药大学",
                major: "针灸推拿学",
                rating: "A+",
                file: "北京中医药大学_针灸推拿学.md",
                employmentRate: 93.8,
                postgraduateRate: 42.3,
                averageSalary: 11000,
                description: "培养公立/民营医疗机构、健康产业等领域的专业人才",
                minScore: 605,
                minRank: 10000,
                planCount: null,
                guidePageNum: 99,
                planPageNum: 104,
                planCount2025: null,
                notes: ""
            },
            {
                school: "华东理工大学",
                major: "高分子材料与工程",
                rating: "A",
                file: "华东理工大学_高分子材料与工程.md",
                employmentRate: 93.8,
                postgraduateRate: 53.5,
                averageSalary: 10000,
                description: "培养高分子研发、材料生产、检测等领域的专业人才",
                minScore: 602,
                minRank: 7000,
                planCount: null,
                guidePageNum: 161,
                planPageNum: 162,
                planCount2025: 2,
                notes: ""
            },
            {
                school: "华东理工大学",
                major: "生物工程",
                rating: "A+",
                file: "华东理工大学_生物工程.md",
                employmentRate: 93.6,
                postgraduateRate: 49.5,
                averageSalary: 10000,
                description: "培养生物医药、制药、医疗检测、科研院所等领域的专业人才",
                minScore: 603,
                minRank: 6500,
                planCount: 4,
                guidePageNum: 161,
                planPageNum: 162,
                planCount2025: 4,
                notes: ""
            },
            {
                school: "河海大学",
                major: "水务工程",
                rating: "A+",
                file: "河海大学_水务工程.md",
                employmentRate: 93.5,
                postgraduateRate: 28.6,
                averageSalary: 12500,
                description: "培养水务规划、资源管理、水处理工程等领域的专业人才",
                minScore: 589,
                minRank: 10000,
                planCount: 3,
                guidePageNum: 174,
                planPageNum: 180,
                planCount2025: 3,
                notes: ""
            },
            {
                school: "南京师范大学",
                major: "生物技术",
                rating: "A",
                file: "南京师范大学_生物技术.md",
                employmentRate: 93.5,
                postgraduateRate: 48.5,
                averageSalary: 9500,
                description: "培养生物医药、检测、科研、农业生物等领域的专业人才",
                minScore: 590,
                minRank: 9600,
                planCount: null,
                guidePageNum: 180,
                planPageNum: 187,
                planCount2025: 5,
                notes: ""
            },
            {
                school: "北京工业大学",
                major: "焊接技术与工程",
                rating: "A+",
                file: "北京工业大学_焊接技术与工程.md",
                employmentRate: 93.2,
                postgraduateRate: 42.5,
                averageSalary: 11000,
                description: "培养装备制造、航空航天、汽车、船舶制造等领域的专业人才",
                minScore: null,
                minRank: 8000,
                planCount: 2,
                guidePageNum: 92,
                planPageNum: 95,
                planCount2025: 2,
                notes: ""
            },
            {
                school: "中国药科大学",
                major: "药学",
                rating: "A+",
                file: "中国药科大学_药学.md",
                employmentRate: 92.8,
                postgraduateRate: 38.5,
                averageSalary: 16750,
                description: "培养药品研发、制药企业、医疗机构、监管等领域的专业人才",
                minScore: 602,
                minRank: 7200,
                planCount: 37,
                guidePageNum: 180,
                planPageNum: 186,
                planCount2025: 37,
                notes: ""
            },
            {
                school: "北京中医药大学",
                major: "中药学4+4",
                rating: "A+",
                file: "北京中医药大学_中药学4+4.md",
                employmentRate: 92.8,
                postgraduateRate: 35.6,
                averageSalary: 14000,
                description: "培养医药研发、中医药医疗、药品质控等领域的专业人才",
                minScore: 605,
                minRank: 10000,
                planCount: 2,
                guidePageNum: 99,
                planPageNum: 104,
                planCount2025: 2,
                notes: ""
            },
            {
                school: "北京工业大学",
                major: "材料科学与工程",
                rating: "A",
                file: "北京工业大学_材料科学与工程.md",
                employmentRate: 92.8,
                postgraduateRate: 51.5,
                averageSalary: 11500,
                description: "培养电子信息材料、新能源材料、先进制造、航空航天材料等领域的专业人才",
                minScore: null,
                minRank: 8000,
                planCount: null,
                guidePageNum: 92,
                planPageNum: 95,
                planCount2025: 2,
                notes: ""
            },
            {
                school: "北京体育大学",
                major: "运动人体科学",
                rating: "A+",
                file: "北京体育大学_运动人体科学.md",
                employmentRate: 92.6,
                postgraduateRate: 36.8,
                averageSalary: 14750,
                description: "培养体育科研、训练中心、体育院校等领域的专业人才",
                minScore: 572,
                minRank: 16000,
                planCount: 1,
                guidePageNum: 104,
                planPageNum: 108,
                planCount2025: 1,
                notes: ""
            },
            {
                school: "北京体育大学",
                major: "运动康复",
                rating: "A+",
                file: "北京体育大学_运动康复.md",
                employmentRate: 92.5,
                postgraduateRate: 32.8,
                averageSalary: 14500,
                description: "培养运动队康复师、医疗康复、体育康复中心等领域的专业人才",
                minScore: 572,
                minRank: 16000,
                planCount: 3,
                guidePageNum: 104,
                planPageNum: 108,
                planCount2025: 3,
                notes: ""
            },
            {
                school: "江南大学",
                major: "纺织工程",
                rating: "A+",
                file: "江南大学_纺织工程.md",
                employmentRate: 91.8,
                postgraduateRate: 60.3,
                averageSalary: 10500,
                description: "培养纺织生产、研发、检测、设计等领域的专业人才",
                minScore: 586,
                minRank: 11000,
                planCount: 5,
                guidePageNum: 175,
                planPageNum: 182,
                planCount2025: 5,
                notes: ""
            }
        ];

        // 初始化页面
        window.onload = function() {
            initializeFilters();
            renderMajorCards();
        };

        // 初始化筛选器
        function initializeFilters() {
            const schools = [...new Set(majorsData.map(item => item.school))];
            const schoolFilter = document.getElementById('schoolFilter');
            schools.forEach(school => {
                const option = document.createElement('option');
                option.value = school;
                option.textContent = school;
                schoolFilter.appendChild(option);
            });
        }

        // 拼音转换工具
        function toPinyin(str) {
            const pinyinMap = {
                '北': 'bei', '京': 'jing', '工': 'gong', '业': 'ye', '大': 'da', '学': 'xue',
                '化': 'hua', '体': 'ti', '育': 'yu', '材': 'cai', '料': 'liao', '科': 'ke',
                '技': 'ji', '术': 'shu', '工': 'gong', '程': 'cheng', '焊': 'han', '接': 'jie',
                '能': 'neng', '源': 'yuan', '氢': 'qing', '运': 'yun', '动': 'dong', '康': 'kang',
                '复': 'fu', '人': 'ren', '体': 'ti', '生': 'sheng', '物': 'wu', '药': 'yao',
                '应': 'ying', '用': 'yong', '高': 'gao', '分': 'fen', '子': 'zi', '中': 'zhong',
                '国': 'guo', '东': 'dong', '理': 'li', '南': 'nan', '河': 'he', '海': 'hai',
                '医': 'yi', '药': 'yao', '针': 'zhen', '灸': 'jiu', '推': 'tui', '拿': 'na'
            };
            let pinyin = '';
            for (let char of str) {
                pinyin += pinyinMap[char] || char;
            }
            return pinyin.toLowerCase();
        }

        // 同义词映射
        const synonymsMap = {
            '化学': ['化工', '化学工程', '化工工程'],
            '计算机': ['信息', '软件', '电脑', '互联网'],
            '机械': ['机电', '自动化', '智能制造'],
            '医学': ['医疗', '临床', '卫生'],
            '经济': ['金融', '财务', '商业'],
            '外语': ['英语', '日语', '法语', '德语'],
            '数学': ['应用数学', '统计'],
            '物理': ['应用物理', '光电'],
            '生物': ['生命科学', '生物技术'],
            '艺术': ['美术', '设计', '音乐'],
            '教育': ['师范', '教学'],
            '管理': ['工商管理', 'MBA', '行政管理'],
            '通信': ['电子', '电信', '无线'],
            '建筑': ['土木', '工民建', '建工'],
            '环境': ['环保', '生态', '可持续'],
            '材料': ['新材料', '复合材料', '高分子']
        };

        // 获取同义词列表
        function getSynonyms(keyword) {
            for (let key in synonymsMap) {
                if (key.includes(keyword) || synonymsMap[key].some(syn => syn.includes(keyword))) {
                    return [key, ...synonymsMap[key]];
                }
            }
            return [keyword];
        }

        // 模糊匹配函数
        function fuzzyMatch(text, keyword) {
            if (!text || !keyword) return false;
            
            // 转换为小写进行比较
            text = text.toLowerCase();
            keyword = keyword.toLowerCase();
            
            // 直接匹配
            if (text.includes(keyword)) return true;
            
            // 拼音匹配
            const textPinyin = toPinyin(text);
            const keywordPinyin = toPinyin(keyword);
            if (textPinyin.includes(keywordPinyin)) return true;
            
            // 同义词匹配
            const synonyms = getSynonyms(keyword);
            return synonyms.some(syn => text.includes(syn.toLowerCase()));
        }

        // 渲染专业卡片的函数更新
        function renderMajorCards(filterText = '', filters = {}) {
            const grid = document.getElementById('majorGrid');
            grid.innerHTML = '';

            // 分词处理搜索关键词
            const keywords = filterText.trim().split(/\s+/).filter(k => k);

            let filteredMajors = majorsData
                .filter(major => {
                    // 如果没有搜索关键词，只检查其他筛选条件
                    if (keywords.length === 0) {
                        return checkOtherFilters(major, filters);
                    }

                    // 搜索匹配
                    const searchText = `${major.school} ${major.major} ${major.description}`;
                    const matchesSearch = keywords.every(keyword =>
                        fuzzyMatch(searchText, keyword)
                    );

                    return matchesSearch && checkOtherFilters(major, filters);
                });

            // 排序处理
            if (filters.sort) {
                const [field, order] = filters.sort.split('-');
                filteredMajors.sort((a, b) => {
                    let valueA, valueB;
                    switch (field) {
                        case 'admission':
                            // 计算录取率（使用最近一年的数据）
                            valueA = calculateAdmissionRate(a);
                            valueB = calculateAdmissionRate(b);
                            break;
                        case 'salary':
                            valueA = a.averageSalary;
                            valueB = b.averageSalary;
                            break;
                        case 'employment':
                            valueA = a.employmentRate;
                            valueB = b.employmentRate;
                            break;
                        case 'postgraduate':
                            valueA = a.postgraduateRate;
                            valueB = b.postgraduateRate;
                            break;
                        default:
                            return 0;
                    }
                    return order === 'asc' ? valueA - valueB : valueB - valueA;
                });
            }

            filteredMajors.forEach(major => {
                const card = createMajorCard(major);
                grid.appendChild(card);
            });
        }

        // 检查其他筛选条件
        function checkOtherFilters(major, filters) {
            // 学校筛选
            const matchesSchool = !filters.school || major.school === filters.school;
            
            // 评级筛选
            const matchesRating = !filters.rating || major.rating === filters.rating;
            
            // 就业率筛选
            const matchesEmployment = !filters.employment || major.employmentRate >= parseFloat(filters.employment);
            
            // 保研率筛选
            const matchesPostgraduate = !filters.postgraduate || major.postgraduateRate >= parseFloat(filters.postgraduate);
            
            // 薪资筛选
            const matchesSalary = !filters.salary || major.averageSalary >= parseFloat(filters.salary);

            return matchesSchool && matchesRating && 
                   matchesEmployment && matchesPostgraduate && matchesSalary;
        }

        // 显示详细信息
        async function showDetails(major) {
            // 直接跳转到对应的MD文件
            const fileName = `学校专业详情/${major.file}`;
            window.location.href = fileName;
        }

        // 关闭详细信息
        function closeDetails() {
            document.getElementById('majorDetails').style.display = 'none';
            document.getElementById('overlay').style.display = 'none';
        }

        // 更新事件监听器
        function updateFilters() {
            const filters = {
                school: document.getElementById('schoolFilter').value,
                rating: document.getElementById('ratingFilter').value,
                employment: document.getElementById('employmentFilter').value,
                postgraduate: document.getElementById('postgraduateFilter').value,
                salary: document.getElementById('salaryFilter').value,
                sort: document.getElementById('sortFilter').value
            };
            
            renderMajorCards(document.getElementById('searchInput').value, filters);
        }

        // 添加事件监听
        document.getElementById('searchInput').addEventListener('input', updateFilters);
        document.getElementById('schoolFilter').addEventListener('change', updateFilters);
        document.getElementById('ratingFilter').addEventListener('change', updateFilters);
        document.getElementById('employmentFilter').addEventListener('change', updateFilters);
        document.getElementById('postgraduateFilter').addEventListener('change', updateFilters);
        document.getElementById('salaryFilter').addEventListener('change', updateFilters);
        document.getElementById('sortFilter').addEventListener('change', updateFilters);

        // 点击遮罩层关闭详情
        document.getElementById('overlay').addEventListener('click', closeDetails);

        // 修改预测录取概率的函数
        function predictAdmission() {
            const score = parseInt(document.getElementById('scoreInput').value);
            const rank = parseInt(document.getElementById('rankInput').value);
            
            if (!score && !rank) {
                alert('请输入高考分数或位次');
                return;
            }

            // 显示推荐区域
            document.getElementById('recommendationSection').style.display = 'block';

            // 更新显示的专业卡片，添加录取概率信息
            const grid = document.getElementById('majorGrid');
            grid.innerHTML = '';

            // 对专业进行排序：优先显示最有可能录取的专业
            const sortedMajors = [...majorsData].sort((a, b) => {
                const chanceA = calculateParallelAdmissionChance(score, rank, a);
                const chanceB = calculateParallelAdmissionChance(score, rank, b);
                return (chanceB || 0) - (chanceA || 0);
            });

            // 生成志愿填报建议
            generateRecommendations(sortedMajors);

            sortedMajors.forEach(major => {
                const admissionChance = calculateParallelAdmissionChance(score, rank, major);
                const card = createMajorCard(major, admissionChance);
                grid.appendChild(card);
            });

            // 显示小猪对话框
            showPigDialog();
        }

        // 显示小猪对话框
        function showPigDialog() {
            document.getElementById('pigDialog').style.display = 'block';
            
            // 可选：5秒后自动关闭
            setTimeout(() => {
                closePigDialog();
            }, 5000);
        }

        // 关闭小猪对话框
        function closePigDialog() {
            document.getElementById('pigDialog').style.display = 'none';
        }

        // 生成志愿填报建议
        function generateRecommendations(sortedMajors) {
            const highRiskSchools = document.getElementById('highRiskSchools');
            const mediumRiskSchools = document.getElementById('mediumRiskSchools');
            const lowRiskSchools = document.getElementById('lowRiskSchools');

            // 清空现有建议
            highRiskSchools.innerHTML = '';
            mediumRiskSchools.innerHTML = '';
            lowRiskSchools.innerHTML = '';

            // 获取用户输入的分数或位次
            const score = parseInt(document.getElementById('scoreInput').value);
            const rank = parseInt(document.getElementById('rankInput').value);
            
            // 如果用户未输入位次，提示用户
            if (!rank) {
                const message = `
                    <div class="no-data-message" style="text-align: center; padding: 20px; color: var(--primary-color);">
                        <p style="font-size: 18px; font-weight: bold;">请输入高考位次以获取个性化志愿推荐</p>
                        <p>系统将根据您的位次计算录取率并推荐志愿</p>
                    </div>
                `;
                highRiskSchools.innerHTML = message;
                return;
            }
            
            // 先根据录取率排序
            const sortedByAdmissionRate = [...sortedMajors].sort((a, b) => {
                let rateA = calculatePersonalAdmissionRate(rank, a) || 0;
                let rateB = calculatePersonalAdmissionRate(rank, b) || 0;
                
                return rateA - rateB; // 从低到高排序，录取率低的放前面（冲刺院校）
            });
            
            // 筛选出录取率合理的院校
            const filteredMajors = sortedByAdmissionRate.filter(major => {
                if (rank && major.minRank) {
                    const personalRate = calculatePersonalAdmissionRate(rank, major);
                    return personalRate !== null && personalRate >= 2.0;
                }
                return false; // 如果没有位次数据，不显示该专业
            });
            
            // 如果过滤后为空，使用原始列表
            const finalSortedMajors = filteredMajors.length > 0 ? filteredMajors : sortedByAdmissionRate;

            // 按30:40:30的比例分配学校
            const totalSchools = finalSortedMajors.length;
            const highCount = Math.floor(totalSchools * 0.3);
            const mediumCount = Math.floor(totalSchools * 0.4);

            // 更新分类标题
            document.querySelector('.recommendation-group:nth-child(1) h4').textContent = '冲刺院校 (30%)';
            document.querySelector('.recommendation-group:nth-child(2) h4').textContent = '稳妥院校 (40%)';
            document.querySelector('.recommendation-group:nth-child(3) h4').textContent = '保底院校 (30%)';

            // 分配学校到不同类别
            finalSortedMajors.forEach((major, index) => {
                const fileName = `学校专业详情/${major.file}`;
                
                // 计算个人录取率
                let admissionRate = calculateAdmissionRate(major);
                let rateDescription = "您的个人录取率";
                let admissionRateDisplay = admissionRate !== null ? admissionRate.toFixed(1) + "%" : "——";
                
                // 根据录取率确定颜色
                let rateColorClass = '';
                if (admissionRate !== null) {
                    if (admissionRate >= 80) {
                        rateColorClass = 'high-admission-rate';
                    } else if (admissionRate >= 40) {
                        rateColorClass = 'medium-admission-rate';
                    } else {
                        rateColorClass = 'low-admission-rate';
                    }
                }
                
                let recommendationLabel = "";
                
                // 为低录取率专业添加警告
                if (admissionRate !== null) {
                    if (admissionRate < 20) {
                        recommendationLabel = `<span style="color: #ff0000; font-weight: bold;">录取难度较大 (${admissionRate.toFixed(1)}%)</span>`;
                    } else if (admissionRate > 90) {
                        recommendationLabel = `<span style="color: #2e7d32; font-weight: bold;">录取几率极高 (${admissionRate.toFixed(1)}%)</span>`;
                    }
                }
                
                const schoolInfo = `
                    <div class="school-item" onclick="window.location.href='${fileName}'">
                        <div class="school-name">${major.school} - ${major.major} ${recommendationLabel}</div>
                        <div class="school-stats-grid">
                            <div class="school-stat tooltip">
                                <div class="stat-label">录取率</div>
                                <div class="stat-value ${rateColorClass}">${admissionRateDisplay}</div>
                                <span class="tooltip-text">
                                    <strong>${rateDescription}</strong><br>
                                    录取率计算公式: (最低录取位次 ÷ 您的位次) × 100%<br>
                                    您的位次: ${rank || '未输入'}<br>
                                    专业最低位次: ${major.minRank || '未知'}<br>
                                    该指标反映了您相对于该专业历史录取分数线的竞争力<br>
                                    <strong>数值越高越容易被录取，最高显示100%</strong>
                                </span>
                            </div>
                            <div class="school-stat">
                                <div class="stat-label">2024计划人数</div>
                                <div class="stat-value">${major.planCount || '暂无数据'}</div>
                            </div>
                            <div class="school-stat">
                                <div class="stat-label">2024最低位次</div>
                                <div class="stat-value">${major.minRank || '暂无数据'}</div>
                            </div>
                            <div class="school-stat">
                                <div class="stat-label">2025计划人数</div>
                                <div class="stat-value">${major.planCount2025 || '暂无数据'}</div>
                            </div>
                        </div>
                        <p style="color: #d32f2f; font-size: 12px; text-align: center; margin-top: 8px;">*招生计划页码：${major.planPageNum || '暂无'}</p>
                        <p style="color: var(--primary-color); font-weight: bold; text-align: center; margin-top: 5px;">点击查看学校详情</p>
                    </div>
                `;

                if (index < highCount) {
                    highRiskSchools.innerHTML += schoolInfo;
                } else if (index < highCount + mediumCount) {
                    mediumRiskSchools.innerHTML += schoolInfo;
                } else {
                    lowRiskSchools.innerHTML += schoolInfo;
                }
            });
        }

        // 根据平行志愿规则计算录取概率
        function calculateParallelAdmissionChance(score, rank, major) {
            if (!major.minRank || !rank) {
                return null; // 如果没有最低位次数据或用户未输入位次，返回null
            }

            let chance = 0;
            // 使用个人录取率作为基础预测值
            const personalAdmissionRate = calculatePersonalAdmissionRate(rank, major);
            
            if (personalAdmissionRate === null) {
                return null;
            }
            
            // 根据个人录取率转换为0-1之间的概率值
            if (personalAdmissionRate >= 150) chance = 0.95;      // 录取率150%以上，几乎必然录取
            else if (personalAdmissionRate >= 120) chance = 0.9;  // 录取率120-150%，极高几率
            else if (personalAdmissionRate >= 100) chance = 0.85; // 录取率100-120%，很高几率
            else if (personalAdmissionRate >= 80) chance = 0.75;  // 录取率80-100%，较高几率
            else if (personalAdmissionRate >= 60) chance = 0.65;  // 录取率60-80%，中等偏上几率
            else if (personalAdmissionRate >= 40) chance = 0.55;  // 录取率40-60%，中等几率
            else if (personalAdmissionRate >= 20) chance = 0.45;  // 录取率20-40%，中等偏下几率
            else if (personalAdmissionRate >= 10) chance = 0.35;  // 录取率10-20%，较低几率
            else chance = 0.2;                                   // 录取率低于10%，低几率

            // 考虑计划招生人数影响
            if (major.planCount) {
                if (major.planCount >= 10) {
                    chance *= 1.1;
                } else if (major.planCount <= 2) {
                    chance *= 0.8; // 小计划专业降低录取概率
                } else {
                    chance *= 0.95;
                }
            } else {
                chance *= 0.85; // 没有计划数的专业降低录取概率
            }

            // 专业评级影响
            if (major.rating === 'A+') {
                chance *= 0.9;
            }

            return Math.min(chance, 1);
        }

        // 创建专业卡片
        function createMajorCard(major, admissionChance = null) {
            const card = document.createElement('div');
            card.className = 'major-card';
            card.onclick = () => showDetails(major);
            
            // 添加鼠标悬停提示
            card.title = '点击查看学校详情';
            
            // 获取输入的分数或位次
            const score = parseInt(document.getElementById('scoreInput').value);
            const rank = parseInt(document.getElementById('rankInput').value);
            
            // 计算录取率 - 如果用户输入了位次，则计算个人录取率，否则显示基准录取率
            let admissionRate = calculateAdmissionRate(major);
            let rateDescription = "您的个人录取率";
            let admissionRateDisplay = admissionRate !== null ? admissionRate.toFixed(1) + "%" : "——";
            
            // 根据录取率确定颜色
            let rateColorClass = '';
            if (admissionRate !== null) {
                if (admissionRate >= 80) {
                    rateColorClass = 'high-admission-rate';
                } else if (admissionRate >= 40) {
                    rateColorClass = 'medium-admission-rate';
                } else {
                    rateColorClass = 'low-admission-rate';
                }
            }
            
            let content = `
                <div class="major-header">
                    <h3>${major.school} - ${major.major}</h3>
                    <span class="rating">评级: ${major.rating || '暂无'}</span>
                </div>
                <div class="stats-grid">
                    <div class="stat-box">
                        <div class="stat-label">就业率</div>
                        <div class="stat-value">${major.employmentRate}%</div>
                    </div>
                    <div class="stat-box">
                        <div class="stat-label">保研率</div>
                        <div class="stat-value">${major.postgraduateRate}%</div>
                    </div>
                    <div class="stat-box">
                        <div class="stat-label">平均薪资</div>
                        <div class="stat-value">${major.averageSalary}元</div>
                    </div>
                    <div class="stat-box tooltip">
                        <div class="stat-label">录取率</div>
                        <div class="stat-value ${rateColorClass}">${admissionRateDisplay}</div>
                        <span class="tooltip-text">
                            <strong>${rateDescription}</strong><br>
                            录取率计算公式: (最低录取位次 ÷ 您的位次) × 100%<br>
                            您的位次: ${rank || '未输入'}<br>
                            专业最低位次: ${major.minRank || '未知'}<br>
                            该指标反映了您相对于该专业历史录取分数线的竞争力<br>
                            <strong>数值越高越容易被录取，最高显示100%</strong>
                        </span>
                    </div>
                </div>
                <div class="admission-grid">
                    <div class="stat-item">
                        <div class="stat-label">2024年计划</div>
                        <div class="stat-value">${major.planCount || '暂无数据'}</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-label">2024年最低位次</div>
                        <div class="stat-value">${major.minRank || '暂无数据'}</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-label">2025年计划</div>
                        <div class="stat-value">${major.planCount2025 || '暂无数据'}</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-label">招生计划页</div>
                        <div class="stat-value">${major.planPageNum ? major.planPageNum + '页' : '暂无数据'}</div>
                    </div>
                </div>
                <p class="description">${major.description}</p>
                <p class="view-details" style="color: var(--primary-color); font-weight: bold; text-align: center; margin-top: 8px;">点击查看学校详情</p>
                <p class="plan-note" style="color: #d32f2f; font-size: 12px; text-align: center; margin-top: 5px;">*招生计划以高考指南招生计划页为准</p>
            `;

            if (admissionChance !== null) {
                const chanceText = (admissionChance * 100).toFixed(1);
                const chanceClass = admissionChance >= 0.7 ? 'high-chance' :
                                  admissionChance >= 0.4 ? 'medium-chance' : 'low-chance';
                content += `
                    <div class="admission-prediction ${chanceClass}">
                        录取概率: ${chanceText}%
                    </div>
                `;
            } else if (rank) {
                content += `
                    <div class="admission-prediction medium-chance">
                        录取概率: 计算中...
                    </div>
                `;
            }

            card.innerHTML = content;
            return card;
        }

        // 计算专业投档优先级
        function calculatePriority(major) {
            if (major.rating === 'A+') return '优先考虑';
            if (major.employmentRate >= 95) return '就业优势';
            if (major.postgraduateRate >= 50) return '深造优势';
            return '普通';
        }

        // 专业调剂建议
        function recommendAdjustment(major) {
            if (major.rating === 'A+' || major.employmentRate >= 95) {
                return '建议服从';
            }
            return '慎重考虑';
        }

        // 计算录取率的函数
        function calculateAdmissionRate(major) {
            if (!major.minRank) {
                return null; // 如果没有最低位次数据，返回null
            }
            
            // 获取用户输入的分数或位次
            const score = parseInt(document.getElementById('scoreInput').value);
            const rank = parseInt(document.getElementById('rankInput').value);
            
            // 如果用户输入了位次，计算个人录取率
            if (rank) {
                return calculatePersonalAdmissionRate(rank, major);
            }
            
            // 用户未输入位次，返回null
            return null;
        }
        
        // 根据学生位次计算个人录取率
        function calculatePersonalAdmissionRate(studentRank, major) {
            if (!major.minRank || !studentRank) {
                return null; // 如果没有数据或用户未输入位次，返回null
            }
            
            // 录取率 = (最低录取位次 ÷ 学生位次) × 100%
            // 位次越小（成绩越好），录取率越高
            let rankRatio = major.minRank / studentRank;
            let admissionRate = rankRatio * 100;
            
            // 确保录取率至少为0.1%，避免显示为0%
            admissionRate = Math.max(admissionRate, 0.1);
            
            // 限制最高录取率为100%
            return Math.min(admissionRate, 100);
        }

        // 添加录取信息相关的CSS样式
        const style = document.createElement('style');
        style.textContent = `
            .admission-info {
                display: flex;
                gap: 10px;
                margin: 10px 0;
            }

            .admission-info .stat-item {
                background-color: #f0f0f0;
                color: var(--primary-color);
                font-weight: bold;
            }

            .major-card .stats {
                flex-wrap: wrap;
                gap: 8px;
            }

            .major-card .stat-item {
                font-size: 13px;
                padding: 4px 12px;
                background-color: #f5f5f5;
                border-radius: 15px;
                color: var(--light-text);
                border: 1px solid var(--border-color);
                white-space: nowrap;
            }
            
            /* 录取率悬停提示样式 */
            .tooltip {
                position: relative;
                display: inline-block;
                cursor: help;
            }

            .tooltip .tooltip-text {
                visibility: hidden;
                width: 320px;
                background-color: rgba(0,0,0,0.8);
                color: #fff;
                text-align: center;
                border-radius: 6px;
                padding: 10px;
                position: absolute;
                z-index: 1;
                bottom: 125%;
                left: 50%;
                transform: translateX(-50%);
                opacity: 0;
                transition: opacity 0.3s;
                font-size: 12px;
                line-height: 1.5;
            }

            .tooltip .tooltip-text::after {
                content: "";
                position: absolute;
                top: 100%;
                left: 50%;
                margin-left: -5px;
                border-width: 5px;
                border-style: solid;
                border-color: rgba(0,0,0,0.8) transparent transparent transparent;
            }

            .tooltip:hover .tooltip-text {
                visibility: visible;
                opacity: 1;
            }

            /* 录取率样式 */
            .high-admission-rate {
                color: #2e7d32 !important;
                font-weight: bold;
            }
            
            .medium-admission-rate {
                color: #f57c00 !important;
                font-weight: bold;
            }
            
            .low-admission-rate {
                color: #c62828 !important;
                font-weight: bold;
            }
        `;
        document.head.appendChild(style);
    </script>
</body>
</html> 